package service.impl;

import entity.AcademyEntity;
import dao.AcademyDao;
import dao.impl.AcademyDaoImpl;
import service.AcademyService;
import util.UUIDUtil;

import java.util.List;
import java.util.Map;

public class AcademyServiceImpl implements AcademyService {

    private final AcademyDao academyDao = new AcademyDaoImpl();
    @Override
    public List<AcademyEntity> getAcademyInfo(String name) {
        List<Map<String,Object>> mapList = academyDao.getAcademyInfo(name);
        return AcademyEntity.mapListToEntityList(mapList);
    }

    @Override
    public int addAcademyInfo(AcademyEntity academy) {
        academy.setId(UUIDUtil.getUUID());
        return academyDao.addAcademyInfo(academy);
    }

    @Override
    public int updateAcademyInfo(AcademyEntity academy) {
        return academyDao.updateAcademyInfo(academy);
    }

    @Override
    public int deleteAcademy(String academyId) {
        return academyDao.deleteAcademy(academyId);
    }

    @Override
    public int batchDeleteAcademy(List<String> ids) {
        return academyDao.batchDeleteAcademy(ids);
    }

    @Override
    public AcademyEntity getAcademyInfoById(String academyId) {
        return AcademyEntity.mapToEntity(academyDao.getAcademyInfoById(academyId));
    }
}
